package com.chapter14.demo1;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class CreateStream {
    public static void main(String[] args) {
        //集合创建流
        List<Integer> list = Arrays.asList(1,3,5,7,9);
        Stream<Integer> stream1 = list.stream();
        stream1.forEach(x-> System.out.println(x));

        //数组创建流
        int[] intArr = {2,4,6,8,10};
        IntStream stream2 = Arrays.stream(intArr);
        stream2.forEach(x-> System.out.println(x));

        //值创建流
        Stream<String> stream3 = Stream.of("one", "two", "three");
        stream3.forEach(x-> System.out.println(x));

    }
}
